package de.davvid.core;

import java.util.Date;
import java.io.*;


public class Settings extends Persistant{	
	public static final int BEGIN_RECORD = 0;
	public static final int FINISH_RECORD = 1;
	
	public int mode;
	public Date startDate, endDate;
	public String summary, note, category, location;

	public Settings() {
		super("Settings");
		
		if(! load()) {
			// No Record in DB yet.
			mode = BEGIN_RECORD;
			startDate = new Date();
			summary = "IHE Hiwi";
			category = "Arbeit";
			location = "UniKa IHE";
		}
	}
	
	// Load Settings from Stream
	public void readObject(DataInputStream stream) throws IOException {
			mode = stream.readInt();
			startDate = new Date(stream.readLong());
			summary = stream.readUTF();
			category = stream.readUTF();
			location = stream.readUTF();
	}
	
	// Save Setting to Stream	
	public void writeObject(DataOutputStream stream) throws IOException {		
			stream.writeInt(mode);
			stream.writeLong(startDate.getTime());
			stream.writeUTF(summary);
			stream.writeUTF(category);
			stream.writeUTF(location);
	}
	
}

